package com.info.zhiduoduo.repository.mapper.partner;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.partner.PartnerVaccineRecordDto;
import com.info.zhiduoduo.repository.entity.partner.PartnerVaccineRecord;

import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PartnerVaccineRecordMapper extends BaseMapper<PartnerVaccineRecord> {

	@Select(" select pvr.*,pa.realname as partnerName,c.compname " +
			" from zdd_partner_vaccine_record pvr " +
			" join zdd_partner_account pa on pa.partnerid = pvr.partnerid and vaccine_flag = 1  " +
			" join zdd_company c on c.compid = pvr.compid " +
			" where pvr.partnerid = #{partnerid} " +
			" and if(#{state}=0, 1=1, pvr.state = #{state}) " +
			" order by id desc")
	List<PartnerVaccineRecordDto> listByPartnerid(int partnerid, int state);

	@Select(" select pvr.*,pa.realname as partnerName,c.compname " +
			" from zdd_partner_vaccine_record pvr " +
			" join zdd_partner_account pa on pa.partnerid = pvr.partnerid and vaccine_flag = 1  " +
			" join zdd_company c on c.compid = pvr.compid " +
			" where pvr.compid = #{compid} " +
			" and if(#{state}=0, 1=1, pvr.state = #{state}) " +
			" and pa.realname like '%${partnerName}%' " +
			" and pvr.contact_name like '%${contactName}%' " +
			" and pvr.company_note like '%${companyNote}%' " +
			" order by id desc ")
	List<PartnerVaccineRecordDto> listByCompid(int compid, String partnerName, String contactName, String companyNote, int state);
}
